package com.binyuan.move.utils;

import java.io.File;

public class FileUtils {

    public static void deleteFolder(File folder) {
        if (folder == null || !folder.exists()) {
            return;
        }

        if (folder.isDirectory()) {
            File[] files = folder.listFiles();
            if (files != null) {
                for (File file : files) {
                    if (file.isDirectory()) {
                        deleteFolder(file); // 递归删除子文件夹
                    } else {
                        file.delete(); // 删除文件
                    }
                }
            }
        }

        // 删除空文件夹或文件
        folder.delete();
    }

}
